<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-06-25 10:05
 * Modified Time: 2019-06-25 10:05
 * Version: 2.0
 */

namespace App\Models;

use Flower\Core\Repository\Contracts\Transformable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Dynamic 理发师动态
 * @package App\Models
 * Author: Happy dong
 * Created Time: 2019-06-25 14:10
 */
class Dynamic  extends Model
{
	use SoftDeletes;
	protected $table = 'dynamic';

	protected $guarded = [];


	/**
	 * 动态资源关联
	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
	 * Author: Happy dong
	 * Created Time: 2019-06-25 14:05
	 * Modified Time : 2019-07-12 10:14
	 */
	public function resource()
	{
		return $this->hasMany(DynamicResource::class, 'dynamic_id', 'id');
	}

	/*
	 * 获取点赞数
	 */
	public function dynamicLike()
    {
        return $this->hasMany(DynamicLike::class,'dynamic_id','id');
    }

    /*
     * 获取某用户的赞
     */
    public function userDynamicLike($member_id)
    {
        return $this->hasOne(DynamicLike::class,'dynamic_id','id')->where('member_id',$member_id);
    }


}